package com.sj.server;

import com.sj.command.*;
import com.sj.common.lang.Const;
import com.sj.pojo.*;

/**
 * Created with IntelliJ IDEA.
 * User: xiaoqi
 * Date: 2022-07-08
 * Time: 上午 10:03
 * Description: 操作指令
 *
 * @author xiaoqi
 * @since 2022-07-08
 */
public class OperationInstruct {

    private OperationInstruct() {

    }

    public static Protocol operationInstruct(String msg) {
        if (msg.startsWith(Const.MAP_PREFIX)) {
            return CommandMap.doing(msg);
        } else if (msg.startsWith(Const.LIST_PREFIX_L) || msg.startsWith(Const.LIST_PREFIX_R)) {
            return CommandList.doing(msg);
        } else if (msg.startsWith(Const.SET_PREFIX) && !msg.startsWith(Const.SET) && !msg.startsWith(Const.STRLEN)) {
            return CommandSet.doing(msg);
        } else if (msg.startsWith(Const.ZSET_PREFIX)) {
            return CommandZset.doing(msg);
        } else {
            return CommandString.doing(msg);
        }
    }


}